//
//  SecondOfCell.m
//  HYHoney
//
//  Created by dllo on 16/1/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SecondOfCell.h"
#import "SecondOfModel.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersionManager.h"
#import "DKNightVersion.h"

@implementation SecondOfCell

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.image = [[UIImageView alloc] init];
        self.labelOfTitle = [[UILabel alloc] init];
        self.labelOfDesc = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.image];
        [self.contentView addSubview:self.labelOfTitle];
        [self.contentView addSubview:self.labelOfDesc];
    }
    return self;
}

- (void)dealloc{

    [_image release];
    [_labelOfTitle release];
    [_labelOfTitle release];
    [super dealloc];
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{

    self.image.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.frame.size.height - 110);
    self.image.layer.cornerRadius = 14;
    self.image.layer.masksToBounds = YES;
    
    
    self.labelOfTitle.frame = CGRectMake(0, self.frame.size.height - 110, self.contentView.frame.size.width, 60);
    self.labelOfTitle.numberOfLines = 0;
    self.labelOfTitle.font = [UIFont boldSystemFontOfSize:15];  // 字体加粗

    
    self.labelOfDesc.frame = CGRectMake(0, self.frame.size.height - 110 + 60, self.contentView.frame.size.width, 40);
    self.labelOfDesc.numberOfLines = 0;
    self.labelOfDesc.font = [UIFont systemFontOfSize:13];
    
}

- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{

    return layoutAttributes;
}


- (void)passmodel:(SecondOfModel *)model{

    [self.image sd_setImageWithURL:[NSURL URLWithString:model.imageUrl] placeholderImage:[UIImage imageNamed:@"jzz"]];
    
    self.labelOfTitle.text = model.title;
    self.labelOfTitle.dk_textColorPicker = DKColorWithRGB(0x000000, 0xe0ffff);
    
    self.labelOfDesc.text = model.briefDesc;
    self.labelOfDesc.dk_textColorPicker = DKColorWithRGB(0x000000, 0xc6e2ff);
}


- (void)layoutSubviews{

    [super layoutSubviews];
}

@end
